<template>
	<view class="wrapper">
		<!-- 返回首页 -->
		<uni-bankhome />
		<view class="verification">验证本人手机号</view>
		<view>
			<u-form :model="ruleForm" label-width="200rpx" ref="uForm">
				<u-form-item label="手机号" prop="realphone">
					<u-input v-model="ruleForm.realphone" placeholder="请输入手机号" />
				</u-form-item>
				<!-- <u-form-item label="姓名" prop="name">
					<u-input v-model="ruleForm.realName" placeholder="请输入完整姓名" />
				</u-form-item>
				<u-form-item label="证件类型" prop="idType">
					<u-input v-model="ruleForm.idType" placeholder="居民身份证" disabled />
				</u-form-item>
				<u-form-item label="身份证" prop="idNumber">
					<u-input v-model="ruleForm.idCardNumber" placeholder="请输入证件号" />
				</u-form-item> -->
			</u-form>
			<u-button :customStyle="{'background':$lightColor,'color':'#fff'}" @click="next">下一步
			</u-button>
		</view>
	</view>
</template>

<script>
	import {
		applyDistribution
	} from "@/api/goods";
	import {
		checkBankno
	} from "@/utils/Foundation";
	import storage from "@/utils/storage.js"
	export default {
		data() {
			return {
				ruleForm: {
					realName: "",
					idCardNumber: "",
					realphone: ''
				},
				rules: {
					realphone: [{
							required: true,
							message: "请输入手机号",
							// 可以单个或者同时写两个触发验证方式
							trigger: "blur",
						},
						{
							validator: (rule, value, callback) => {
								return this.$u.test.mobile(value);
							},
							message: "手机号输入不正确",
							trigger: ["change", "blur"],
						},
					],
					realName: [{
							required: true,
							message: "请输入姓名",
							// 可以单个或者同时写两个触发验证方式
							trigger: "blur",
						},
						{
							validator: (rule, value, callback) => {
								return this.$u.test.chinese(value);
							},
							message: "姓名输入不正确",
							trigger: ["change", "blur"],
						},
					],
					idCardNumber: [{
							required: true,
							message: "请输入身份证",
							trigger: "blur",
						},
						{
							validator: (rule, value, callback) => {
								return this.$u.test.idCard(value);
							},
							message: "身份证号码不正确",
							trigger: ["change", "blur"],
						},
					]
				}
			}
		},
		methods: {
			next() {
				this.$refs.uForm.validate((valid) => {
					if (valid) {
						let userInfo = storage.getUserInfo()
						if (userInfo.mobile === this.ruleForm.realphone) {
							wx.navigateTo({
								url: './editPassword?type=forget'
							})
						} else {
							uni.showToast({
								title: "手机号验证失败",
								duration: 2000,
								icon: "none",
							});
						}
					} else {
						uni.showToast({
							title: "请填写手机号",
							duration: 2000,
							icon: "none",
						});
					}
				});

			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
	}
</script>
<style lang="scss" scoped>
	.wrapper {
		padding: 32rpx;
	}

	.verification {
		height: 280rpx;
		line-height: 280rpx;
		text-align: center;
		font-size: 40rpx;
	}
</style>
